Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix ResponseFactory::map() Method Not Found Error in CallToolWithExecutor
For issue: #358
Description
This PR fixes a critical bug in
CallToolWithExecutorwhere the code attempts to call->map()directly on aResponseFactoryobject, causing aBadMethodCallExceptionwhen executing MCP tools. The fix ensures that->responses()is called first to get the underlying Collection before using->map()and->contains().Problem
When executing MCP tools via Laravel Boost, the server crashes with:
This occurs because
ResponseFactorydoesn't have amap()method. According to theResponseFactoryAPI inlaravel/mcp, you must first call->responses()to get the underlyingCollection, then call->map()on that collection.Root Cause
In
src/Mcp/Methods/CallToolWithExecutor.phpat line 62, the code was calling->map()directly on aResponseFactoryobject:However, the callback receives a
ResponseFactoryobject (not a Collection), which doesn't havemap()orcontains()methods.Solution
The fix updates the callback to call
->responses()first to get the Collection, then call->map()and->contains()on that collection:Changes Made
src/Mcp/Methods/CallToolWithExecutor.php$responsesto$responseFactoryto better reflect the actual type->responses()calls before->map()and->contains()to access the underlying CollectionBenefit to End Users
get-config,application-info,tinker) without the server crashingWhy This Doesn't Break Existing Features
ResponseFactoryAPICallToolWithExecutorwill continue to work, but now correctlyHow This Makes Building Web Applications Easier
Related Issues
This fixes the bug described in the issue where MCP tools fail to execute with
BadMethodCallException: Method Laravel\Mcp\ResponseFactory::map does not exist.